package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.fabu.FabuBbBean;
import com.lwj.liwanjia.impl.FabuBbView;
import com.lwj.liwanjia.model.FabuBbModel;

import java.io.File;
import java.util.List;

import rx.Subscriber;

/**
 * Created by Administrator on 2018/1/14.
 */

public class FabuBbPresenter {
    private FabuBbModel fabuBbModel;
    private FabuBbView fabuBbView;

    public FabuBbPresenter(FabuBbView fabuBbView) {
        this.fabuBbView = fabuBbView;
        fabuBbModel = new FabuBbModel();
    }

    public void uploadBb(List<File> files, String token) {
        fabuBbModel.uploadBb(files, token, new Subscriber<FabuBbBean>() {
            @Override
            public void onCompleted() {
                fabuBbView.hideProgress();
            }

            @Override
            public void onError(Throwable e) {
                fabuBbView.showError((Exception) e);
                fabuBbView.hideProgress();
            }

            @Override
            public void onNext(FabuBbBean fabuBbBean) {
                fabuBbView.uploadBb(fabuBbBean);
            }

            @Override
            public void onStart() {
                super.onStart();
                fabuBbView.showProgress();
            }
        });
    }
}
